package misc;

import engine.UnitAction;
import engine.data.Map;
import engine.data.Unit;

public final class Util {

	public static short computeDeltaX(final int direction) {
		short dX = 0;
		switch (direction) {
			case UnitAction.MOVE_LEFT:
			case UnitAction.MOVE_UP_LEFT:
			case UnitAction.MOVE_DOWN_LEFT:
				dX = -1;
				break;
			case UnitAction.MOVE_RIGHT:
			case UnitAction.MOVE_UP_RIGHT:
			case UnitAction.MOVE_DOWN_RIGHT:
				dX = 1;
				break;
			default:
				break;
		}
		return dX;
	}
	


	public static short computeDeltaY(final Unit unit, final Map map, final int direction) {
		short dY = 0;
		switch (direction) {
			case UnitAction.MOVE_UP:
			case UnitAction.MOVE_UP_LEFT:
			case UnitAction.MOVE_UP_RIGHT:
				if (unit.y > 0)
					dY = -1;
				break;
			case UnitAction.MOVE_DOWN:
			case UnitAction.MOVE_DOWN_LEFT:
			case UnitAction.MOVE_DOWN_RIGHT:
				if (unit.y < map.height - 1)
					dY = 1;
				break;
			default:
				break;
		}
		return dY;
	}
}
